<?php
header("Content-Type:text/html; charset=utf-8");
include_once('../inc/init.php');
include_once('../inc/cache.php');
include_once('inc/adminfun.php');
if(!isAdmin()){
	exit("请登录");
}

$action=strFilter($_GET['action']);
switch($action){
		
	case "delattachment":
		try{
			$delaid=$_POST['delaid'];
			if(is_array($delaid)) {
				$aidstr=implode(",",$delaid);
				$attrows=$db->row_select("attachments","id in ({$aidstr})");
				foreach($attrows as $row){
					$filepath="../uploadfile/attachment/".$row['filepath'];
					if(file_exists($filepath)){
						@unlink($filepath);
					}
					$db->row_delete("attachments","id={$row['id']}");
				}
				echo("y");
			}else{
				echo("参数错误");
			}
		}catch(Exception $e){
			echo($e);
		}
	break;

	case "savesettings":
		$settings = $_POST['settings'];
		try{
			saveSettings($settings);
			writeSettingsCache();
			echo("y");
		}catch(Exception $e){
			echo($e);
		}
		
	break;	
		
	default:
		echo"No Such Action";
	break;
}?>
